package com.itheima.tcp.socketFile1;

import java.io.*;
import java.net.Socket;

public class ClientFile {
    public static void main(String[] args) throws IOException {
        String host = "127.0.0.1";
        int port = 10000;
        Socket socket = new Socket(host,port);
        long l = System.currentTimeMillis();
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("day16_网络编程\\ClientDir\\img.jpg"));
        BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());
        byte[] bytes = new byte[1024];
        int len ;
        while ((len = bis.read(bytes)) != -1){
            bos.write(bytes,0,len);
            bos.flush();
        }

        socket.shutdownOutput();

        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String line;
        while ((line = br.readLine()) != null){
            System.out.println(line);
        }
        bis.close();
        socket.close();

    }
}
